home *** CD-ROM | disk | FTP | other *** search
- unit Frunit;
- { PC Plus sample Delphi program. A simple French verb conjugator - mark 3 }
- { This now deals with regular ER, IR and RE verbs. It illustrates the use }
- { of standard Pascal procedures }
-
- interface
-
- uses
- SysUtils, WinTypes, WinProcs, Messages, Classes, Graphics, Controls,
- Forms, Dialogs, StdCtrls;
-
- type
- TForm1 = class(TForm)
- ListBox1: TListBox;
- Edit1: TEdit;
- Label1: TLabel;
- Button1: TButton;
- procedure Button1Click(Sender: TObject);
- private
- { Private declarations }
- public
- { Public declarations }
- end;
-
- var
- Form1: TForm1;
-
- implementation
-
- {$R *.DFM}
-
- procedure ConjugateERverb( vStem : string );
- { Note that this is a basic Pascal procedure rather than
- an Object Pascal 'method'. Unlike the methods created by Delphi
- itself, the procedure name does not use dot-notation
- (e.g. Form1.someProcedureName)
- For this reason, other Form1 methods are not automatically
- 'visible' to this procedure. This explains why we've had to
- call these methods in this manner:
- Form1.ListBox1.Items.Add('Je ' + vStem + 'e');
- We could turn the procedure into a 'method' of Form1 by declaring it as:
- Form1.ConjugateERverb
- In which case, other Form1 methods would be visible, and could be
- called using the syntax:
- ListBox1.Items.Add('Je ' + vStem + 'e');
- More on this next month! }
- begin
- Form1.ListBox1.Items.Clear;
- Form1.ListBox1.Items.Add('Je ' + vStem + 'e');
- Form1.ListBox1.Items.Add('Tu ' + vStem + 'es' );
- Form1.ListBox1.Items.Add('Il ' + vStem + 'e' );
- Form1.ListBox1.Items.Add('Elle ' + vStem + 'e' );
- Form1.ListBox1.Items.Add('Nous ' + vStem + 'ons' );
- Form1.ListBox1.Items.Add('Vous ' + vStem + 'ez' );
- Form1.ListBox1.Items.Add('Ils ' + vStem + 'ent');
- Form1.ListBox1.Items.Add('Elles ' + vStem + 'ent');
- end;
-
- procedure ConjugateREverb( vStem : string );
- begin
- Form1.ListBox1.Items.Clear;
- Form1.ListBox1.Items.Add('Je ' + vStem + 's');
- Form1.ListBox1.Items.Add('Tu ' + vStem + 's' );
- Form1.ListBox1.Items.Add('Il ' + vStem );
- Form1.ListBox1.Items.Add('Elle ' + vStem );
- Form1.ListBox1.Items.Add('Nous ' + vStem + 'ons' );
- Form1.ListBox1.Items.Add('Vous ' + vStem + 'ez' );
- Form1.ListBox1.Items.Add('Ils ' + vStem + 'ent');
- Form1.ListBox1.Items.Add('Elles ' + vStem + 'ent');
- end;
-
- procedure ConjugateIRverb( vStem : string );
- begin
- Form1.ListBox1.Items.Clear;
- Form1.ListBox1.Items.Add('Je ' + vStem + 'is');
- Form1.ListBox1.Items.Add('Tu ' + vStem + 'is' );
- Form1.ListBox1.Items.Add('Il ' + vStem + 'it' );
- Form1.ListBox1.Items.Add('Elle ' + vStem + 'it' );
- Form1.ListBox1.Items.Add('Nous ' + vStem + 'issons' );
- Form1.ListBox1.Items.Add('Vous ' + vStem + 'issez' );
- Form1.ListBox1.Items.Add('Ils ' + vStem + 'issent');
- Form1.ListBox1.Items.Add('Elles ' + vStem + 'issent');
- end;
-
- procedure TForm1.Button1Click(Sender: TObject);
- var { --- Declare 3 string variables --- }
- verb, { the verb specified by the user }
- verbStem, { the verb minus its 2-letter ending }
- verbEnd : string; { the 2-letter ending }
- begin
- verb := Edit1.Text;
- { check that the user has entered something... }
- if verb = '' then
- Caption := 'You must enter a verb!'
- else
- begin {... if so, then }
- { find the stem and the ending of the verb }
- verbStem := copy( verb, 1, length(verb)-2 );
- verbEnd := copy( verb, length(verb) -1, 2 );
- Caption := 'This is an ' + verbEnd + ' verb.';
- { find type of verb and call appropriate proc }
- if LowerCase( verbEnd ) = 'er' then
- ConjugateERverb( verbStem )
- else
- if LowerCase( verbEnd ) = 're' then
- ConjugateREverb( verbStem )
- else
- if LowerCase( verbEnd ) = 'ir' then
- ConjugateIRverb( verbStem )
- else { if this isn't an ER, RE or IR verb, show error msg... }
- Caption := 'You must enter an ER, RE or IR verb!';
- end;
- end;
-
- end.
-